package leetcode.editor.test;


import org.junit.Test;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

public class RemoveClass {
    /**
     * LinkedList和ArrayList都不能使用基础迭代器删除元素
     */
    @Test
    public void test1() {
        LinkedList<Integer> linkedList = new LinkedList<>();
        for (int i = 0; i < 10; i++) {
            linkedList.add(i);
        }
        linkedList.removeIf(s -> s == 5);
        System.out.println(linkedList.size());
    }

    @Test
    public void test2() {
        ArrayList<Integer> arrayList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            arrayList.add(i);
        }
        arrayList.removeIf(s->s==9);
        System.out.println(arrayList.size());
    }
}
